home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77655_user_new.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  22.8 KB  |  654 lines

  1. <%@ Language=VBScript   %>
  2. <%    Option Explicit     %>
  3. <%
  4.     '------------------------------------------------------------------------- 
  5.     ' user_prop.asp : get's and set's the user properties.
  6.     '
  7.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  8.     '
  9.     ' Date            Description
  10.     ' 15-jan-01        Creation date
  11.     '-------------------------------------------------------------------------
  12. %>
  13.     <!-- #include virtual="/admin/inc_framework.asp" -->
  14.     <!-- #include file="inc_usersngroups.asp" -->
  15. <%
  16.     '-------------------------------------------------------------------------
  17.     ' Global Constants and Variables
  18.     '-------------------------------------------------------------------------
  19.  
  20.     ' Name of this source file
  21.     Const SOURCE_FILE = "User_new.asp"
  22.     
  23.     ' Flag to toggle optional tracing output
  24.     Const ENABLE_TRACING = TRUE
  25.  
  26.     Dim rc                        'framework variables
  27.     Dim page                    'framework variables
  28.     
  29.     Dim idTabGeneral                    'framework variables
  30.     '-------------------------------------------------------------------------
  31.     ' Global Form Variables
  32.     '-------------------------------------------------------------------------
  33.     
  34.     Dim F_strUsername            'User Name
  35.     Dim F_strFullname            'Full Name
  36.     Dim F_strDescription        'Description
  37.     Dim F_strPassword            'Password
  38.     Dim F_strConfirmpassword    'Confirm Password
  39.     Dim F_strIsChecked            'Used to store checked/unchecked
  40.     Dim F_blnIsChecked          'var for getting user info
  41.     Dim F_strHDIsChecked        'var for store state of HomeDirectory's checkbox
  42.     Dim F_strHomeDirectory      'Home Directory
  43.     Dim F_strDefaultHomeDir     'Default path by OEM
  44.         
  45.     
  46.     'Flag  for setting disable property
  47.     CONST UF_ACCOUNTDISABLE    = &H0002
  48.     Const N_NONUNIQUEUSERNAME_ERRNO        = &H800708B0
  49.     Const N_USERNAMEINVALID_ERRNO        = &H8007089A
  50.     Const N_PASSWORD_COMPLEXITY_ERRNO    = &H800708C5
  51.     Const N_GROUP_EXISTS_ERRNO            = &H80070563 
  52.      
  53.     '------------------------------------------------------------------------
  54.     'Start of localization content
  55.     '------------------------------------------------------------------------
  56.     Dim L_PAGETITLE_TEXT
  57.     Dim L_USERNAME_TEXT
  58.     Dim L_FULLNAME_TEXT
  59.     Dim L_DESCRIPTION_TEXT
  60.     Dim L_PASSWORD_TEXT
  61.     Dim L_CONFIRMPASSWORD_TEXT
  62.     Dim L_USERDISABLED_TEXT
  63.     Dim L_NOINPUTDATA_TEXT            
  64.     Dim L_TABPROPSHEET_TEXT            
  65.     Dim L_TABLEHEADING_TEXT            
  66.     Dim L_GENERAL_TEXT    
  67.     Dim L_HOMEDIRECTORY_TEXT
  68.     Dim L_HOMEPATH_TEXT
  69.  
  70.     Dim L_ENTERNAME_ERRORMESSAGE
  71.     Dim L_PASSWORDNOTMATCH_ERRORMESSAGE
  72.     Dim L_ADSI_ERRORMESSAGE
  73.     Dim L_INVALIDCHARACTER_ERRORMESSAGE
  74.     Dim L_NONUNIQUEUSERNAME_ERRORMESSAGE
  75.     Dim L_COMPUTERNAME_ERRORMESSAGE
  76.     Dim L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  77.     Dim L_GROUP_EXISTS_ERRORMESSAGE
  78.     Dim L_HOMEDIRECTORY_ERRORMESSAGE
  79.     Dim L_CREATEHOMEDIRECTORY_ERRORMESSAGE
  80.     Dim L_CREATEHOMEDIRECTORY_EXISTMESSAGE
  81.     
  82.     L_NOINPUTDATA_TEXT                    = objLocMgr.GetString("usermsg.dll","&H40300019", varReplacementStrings)
  83.     L_TABPROPSHEET_TEXT                    = objLocMgr.GetString("usermsg.dll","&H4030001A", varReplacementStrings)
  84.     L_TABLEHEADING_TEXT                    = objLocMgr.GetString("usermsg.dll","&H4030001B", varReplacementStrings)
  85.     L_GENERAL_TEXT                        = objLocMgr.GetString("usermsg.dll","&H4030001C", varReplacementStrings)
  86.  
  87.     L_PAGETITLE_TEXT                    = objLocMgr.GetString("usermsg.dll","&H4030001D", varReplacementStrings)
  88.     L_USERNAME_TEXT                     = objLocMgr.GetString("usermsg.dll","&H4030001E", varReplacementStrings)
  89.     L_FULLNAME_TEXT                     = objLocMgr.GetString("usermsg.dll","&H4030001F", varReplacementStrings)
  90.     L_DESCRIPTION_TEXT                    = objLocMgr.GetString("usermsg.dll","&H40300020", varReplacementStrings)
  91.     L_PASSWORD_TEXT                     = objLocMgr.GetString("usermsg.dll","&H40300021", varReplacementStrings)
  92.     L_CONFIRMPASSWORD_TEXT                = objLocMgr.GetString("usermsg.dll","&H40300022", varReplacementStrings)
  93.     L_USERDISABLED_TEXT                    = objLocMgr.GetString("usermsg.dll","&H40300023", varReplacementStrings)
  94.     L_HOMEDIRECTORY_TEXT                = objLocMgr.GetString("usermsg.dll","&H40300052", varReplacementStrings)
  95.     L_HOMEPATH_TEXT                     = objLocMgr.GetString("usermsg.dll","&H40300054", varReplacementStrings)
  96.     
  97.     L_COMPUTERNAME_ERRORMESSAGE         = objLocMgr.GetString("usermsg.dll","&HC0300024", varReplacementStrings)
  98.     L_ENTERNAME_ERRORMESSAGE            = objLocMgr.GetString("usermsg.dll","&HC0300025", varReplacementStrings)
  99.     L_PASSWORDNOTMATCH_ERRORMESSAGE     = objLocMgr.GetString("usermsg.dll","&HC0300026", varReplacementStrings)
  100.     L_NONUNIQUEUSERNAME_ERRORMESSAGE    = objLocMgr.GetString("usermsg.dll","&HC0300027", varReplacementStrings)
  101.     L_INVALIDCHARACTER_ERRORMESSAGE     = objLocMgr.GetString("usermsg.dll","&HC0300028", varReplacementStrings)
  102.     L_ADSI_ERRORMESSAGE                    = objLocMgr.GetString("usermsg.dll","&HC0300029", varReplacementStrings)
  103.     L_PASSWORD_COMPLEXITY_ERRORMESSAGE    = objLocMgr.GetString("usermsg.dll","&HC030002A", varReplacementStrings)
  104.     L_GROUP_EXISTS_ERRORMESSAGE            = objLocMgr.GetString("usermsg.dll","&HC030002B", varReplacementStrings)
  105.     L_HOMEDIRECTORY_ERRORMESSAGE        = objLocMgr.GetString("usermsg.dll","&HC0300053", varReplacementStrings)
  106.     L_CREATEHOMEDIRECTORY_ERRORMESSAGE  = objLocMgr.GetString("usermsg.dll","&HC0300057", varReplacementStrings)
  107.     L_CREATEHOMEDIRECTORY_EXISTMESSAGE  = objLocMgr.GetString("usermsg.dll","&HC0300059", varReplacementStrings)
  108.     
  109.     '------------------------------------------------------------------------
  110.     'END of localization content
  111.     '------------------------------------------------------------------------
  112.     
  113.     ' Create a Tabbed Property Page
  114.     rc = SA_CreatePage(L_PAGETITLE_TEXT, "", PT_TABBED, page )
  115.     
  116.     ' Add one tab
  117.     rc = SA_AddTabPage( page,L_PAGETITLE_TEXT, idTabGeneral)
  118.     
  119.     ' Show the page
  120.     rc = SA_ShowPage( page )
  121.     
  122.     '-------------------------------------------------------------------------
  123.     'Function:                OnInitPage()
  124.     'Description:            Called to signal first time processing for this page.
  125.     '                        Use this method to do first time initialization tasks
  126.     'Input Variables:        PageIn,EventArg
  127.     'Output Variables:        PageIn,EventArg
  128.     'Returns:                True/False
  129.     'Global Variables:        None
  130.     '-------------------------------------------------------------------------    
  131.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  132.  
  133.         If ( ENABLE_TRACING ) Then 
  134.             Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  135.         End If
  136.     
  137.         OnInitPage = FALSE
  138.         
  139.         Dim objReg
  140.         Dim strDefaultHomeDir
  141.         
  142.         Set objReg = RegConnection()
  143.         
  144.         strDefaultHomeDir = GetRegKeyValue( objReg,_
  145.                                      CONST_USERGROUP_KEYNAME,_
  146.                                      CONST_USERDIR_VALUENAME,_
  147.                                      CONST_STRING )
  148.                              
  149.         If ( Len(strDefaultHomeDir) <= 0 ) Then
  150.             F_strDefaultHomeDir = CONST_DEFAULTHOMEDIR
  151.         Else 
  152.             F_strDefaultHomeDir = strDefaultHomeDir
  153.         End If                                
  154.                     
  155.         F_strHomeDirectory = ""
  156.         F_strHDIsChecked = "unchecked"
  157.         
  158.         Set objReg = nothing
  159.         
  160.         OnInitPage = TRUE
  161.     End Function
  162.     
  163.     '-------------------------------------------------------------------------
  164.     'Function:                OnPostBackPage()
  165.     'Description:            Called to signal that the page has been posted-back.
  166.     'Input Variables:        PageIn,EventArg
  167.     'Output Variables:        None
  168.     'Returns:                True/False
  169.     'Global Variables:        None
  170.     '-------------------------------------------------------------------------
  171.     Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  172.         If ( ENABLE_TRACING ) Then 
  173.             Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage")
  174.         End If
  175.         
  176.         'Only one table in the page,so nothing need to do here.            
  177.         OnPostBackPage = TRUE
  178.     End Function
  179.     
  180.     '-------------------------------------------------------------------------
  181.     'Function:                OnServeTabbedPropertyPage()
  182.     'Description:            Called when the page needs to be served.Use this 
  183.     '                        method to serve content
  184.     'Input Variables:        PageIn,EventArg,iTab,bIsVisible
  185.     'Output Variables:        PageIn,EventArg
  186.     'Returns:                True/False
  187.     'Global Variables:        idTabGeneral
  188.     '            TRUE to indicate not problems occured. FALSE to indicate errors.
  189.     '            Returning FALSE will cause the page to be abandoned.
  190.     '-------------------------------------------------------------------------    
  191.     Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  192.                                                     ByVal iTab, _
  193.                                                     ByVal bIsVisible, ByRef EventArg)
  194.         If ( ENABLE_TRACING ) Then 
  195.             Call SA_TraceOut(SOURCE_FILE, "OnServeTabbedPropertyPage")
  196.         End If
  197.         
  198.         ' Emit Web Framework required functions
  199.         Call ServeCommonJavaScript()
  200.  
  201.         ' Emit content for the requested tab
  202.         Call ServeTab1(PageIn, bIsVisible)
  203.             
  204.         OnServeTabbedPropertyPage = TRUE
  205.     End Function
  206.  
  207.     
  208.     '-------------------------------------------------------------------------
  209.     'Function:                OnSubmitPage()
  210.     'Description:            Called when the page has been submitted for processing.
  211.     '                        Use this method to process the submit request.
  212.     'Input Variables:        PageIn,EventArg
  213.     'Output Variables:        PageIn,EventArg
  214.     'Returns:                True/False
  215.     'Global Variables:        F_(*)
  216.     '-------------------------------------------------------------------------
  217.     Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  218.         If ( ENABLE_TRACING ) Then 
  219.             Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage")
  220.         End If
  221.             
  222.         F_strUsername            =Trim(Request.Form("txtUserName"))
  223.         F_strFullname            =Trim(Request.Form("txtFullName") )
  224.         F_strDescription        =Trim(Request.Form("txtDescription"))
  225.         F_strPassword            =Trim(Request.Form("pwdPassword"))
  226.         F_strConfirmpassword    =Trim(Request.Form("pwdConfirmPassword"))
  227.         F_blnIsChecked          =Trim(Request.Form("chkUserDisabled"))
  228.         
  229.         F_strHDIschecked        =Trim(Request.Form("chkHomePath"))
  230.         F_strHomeDirectory      =Trim(Request.Form("txtHomeDirectory"))
  231.         F_strDefaultHomeDir     =Trim(Request.Form("hdnDefaultDir"))                
  232.  
  233.         If ( Len(F_blnIsChecked  ) <= 0 ) Then
  234.             F_blnIsChecked   = FALSE
  235.         End If
  236.         
  237.         If ( F_blnIsChecked   ) Then
  238.             F_strIsChecked = "checked"
  239.         Else
  240.             F_strIsChecked = ""
  241.         End If
  242.         
  243.         OnSubmitPage = CreateUser() 
  244.             
  245.     End Function
  246.     
  247.     '-------------------------------------------------------------------------
  248.     'Function:                OnClosePage()
  249.     'Description:            Called when the page is about closed.Use this method
  250.     '                        to perform clean-up processing
  251.     'Input Variables:        PageIn,EventArg
  252.     'Output Variables:        None
  253.     'Returns:                True/False
  254.     'Global Variables:        None
  255.     '-------------------------------------------------------------------------
  256.     Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  257.         If ( ENABLE_TRACING ) Then 
  258.             Call SA_TraceOut(SOURCE_FILE, "OnClosePage")
  259.         End If
  260.     
  261.         OnClosePage = TRUE
  262.     End Function
  263.     
  264.     '-------------------------------------------------------------------------
  265.     'Function name:            CreateUser
  266.     'Description:            Creating the NewUser
  267.     'Input Variables:        None
  268.     'Output Variables:        None
  269.     'Returns:                (True / Flase )
  270.     'Global Variables:        None
  271.     '                        In:F_strFullname               'Fullname
  272.     '                        In:F_strDescription               'Description
  273.     '                        In:F_strPassword               'Password
  274.     '                        In:F_strUsername               'Username
  275.     '                        In:F_blnIsChecked                 '
  276.     '                        In:L_ADSI_ERRORMESSAGE                    'ADSI error message
  277.     '                        In:L_NONUNIQUEUSERNAME_ERRORMESSAGE        'Username allready exists error
  278.     '                        In:L_SPECIFIEDUSERNAMEINVALID_ERRORMESSAGE 'Invalid User error message
  279.     '                        In:L_PASSWORD_COMPLEXITY_ERRORMESSAGE   'Password Complexity error
  280.     ' True ->If Implemented properly
  281.     ' False->If Not Implemented
  282.     ' If ADSI Error, calls ServeFailurePage with the error string
  283.     ' L_ADSI_ERRORMESSAGE.
  284.     ' If Password Complexity error, calls SetErrMsg with the error string
  285.     ' L_PASSWORD_COMPLEXITY_ERRORMESSAGE.
  286.     ' Username allready exists, calls SetErrMsg with the error string
  287.     ' L_NONUNIQUEUSERNAME_ERRORMESSAGE.
  288.     ' If ADSI Error, calls SetErrMsg with the error string
  289.     ' L_ADSI_ERRORMESSAGE.
  290.     ' Const:UF_ACCOUNTDISABLE   for setting disable property
  291.     '--------------------------------------------------------------------------
  292.     Function CreateUser()
  293.         Err.Clear
  294.         on error resume next
  295.  
  296.         Dim objComputer
  297.         Dim objUser
  298.         Dim objFileSystem
  299.         Dim flagUserFlags
  300.         Dim strComputerName         'Stores the Computer Name
  301.         Dim strHomeDirectory
  302.         Dim bReturn
  303.         
  304.         CreateUser = false
  305.  
  306.         If (F_strHDIschecked = "checked") Then
  307.             strHomeDirectory = F_strHomeDirectory
  308.         Else
  309.             strHomeDirectory = ""
  310.         End If
  311.  
  312.         Set objFileSystem=createobject("scripting.FileSystemObject")
  313.         If Err.number <> 0 Then
  314.             SetErrMsg L_CREATEHOMEDIRECTORY_ERRORMESSAGE
  315.             Exit Function
  316.         End If
  317.  
  318.         
  319.         ' Getting the local computer name by calling the function
  320.         strComputerName = GetComputerName()
  321.  
  322.         Set objComputer =GetObject("WinNT://" & strComputerName & ",computer")
  323.  
  324.         'ADSI error message
  325.         If Err.number <> 0 Then
  326.             Call ServeFailurePage(L_ADSI_ERRORMESSAGE,1)
  327.             CreateUser=false
  328.             Exit function
  329.         End if
  330.  
  331.         Set objUser = objComputer.Create("user" , F_strUsername )
  332.  
  333.         'ADSI error message
  334.         If Err.number <> 0 Then
  335.             Call ServeFailurePage(L_ADSI_ERRORMESSAGE,1)
  336.             CreateUser=false
  337.             Exit function
  338.         End if
  339.  
  340.         objUser.setPassword(F_strPassword)
  341.         objUser.FullName        = F_strFullname
  342.         objUser.Description     = F_strDescription
  343.         
  344.         If ( strHomeDirectory <> "" ) Then
  345.             objUser.HomeDirectory   = strHomeDirectory
  346.         End If
  347.         
  348.         If F_blnIsChecked   Then
  349.             flagUserFlags = objUser.UserFlags OR UF_ACCOUNTDISABLE
  350.             objUser.Put "UserFlags", flagUserFlags
  351.         End If
  352.         objUser.SetInfo()
  353.  
  354.         If Err.number <> 0 Then
  355.             'The username already exists
  356.             If Err.number = N_NONUNIQUEUSERNAME_ERRNO Then      
  357.                SetErrMsg  L_NONUNIQUEUSERNAME_ERRORMESSAGE
  358.             'Specified username is invalid
  359.             Elseif Err.number = N_USERNAMEINVALID_ERRNO Then  
  360.                 SetErrMsg  L_INVALIDCHARACTER_ERRORMESSAGE
  361.             'Password Complexity Error Message
  362.             Elseif Err.Number = N_PASSWORD_COMPLEXITY_ERRNO Then  
  363.                 SetErrMsg L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  364.             Elseif Err.Number = N_GROUP_EXISTS_ERRNO Then
  365.                 SetErrMsg L_GROUP_EXISTS_ERRORMESSAGE
  366.             Else                                 
  367.             'User could not be created
  368.                 SetErrMsg L_ADSI_ERRORMESSAGE
  369.             End if
  370.             CreateUser=false
  371.             Exit Function
  372.         End If
  373.  
  374.         If ( strHomeDirectory <> "" ) Then
  375.             bReturn = CreateHomeDirectory( strHomeDirectory, objFileSystem )
  376.             If( bReturn = CONST_CREATDIRECTORY_ERROR ) Then
  377.                 SetErrMsg L_CREATEHOMEDIRECTORY_ERRORMESSAGE
  378.                 Exit Function
  379.             ElseIf( bReturn = CONST_CREATDIRECTORY_EXIST ) Then
  380.                 SetErrMsg L_CREATEHOMEDIRECTORY_EXISTMESSAGE
  381.                 Exit Function
  382.             End If
  383.         End If    
  384.         If ( strHomeDirectory <> "" ) Then
  385.             Call SetHomeDirectoryPermission( strComputerName, F_strUsername, strHomeDirectory ) 
  386.         End If
  387.             
  388.         Set objComputer    =    Nothing
  389.         Set objUser        =    Nothing     
  390.         Set objFileSystem = Nothing
  391.         
  392.         CreateUser=true
  393.     End Function
  394.     
  395.     '-------------------------------------------------------------------------
  396.     'Function:                ServeTab1
  397.     'Description:            Serves in getting the page for tab1
  398.     'Input Variables:        PageIn,bIsVisible
  399.     'Output Variables:        PageIn
  400.     'Returns:                gc_ERR_SUCCESS 
  401.     'Global Variables:        L_(*) All
  402.     '-------------------------------------------------------------------------
  403.     Function ServeTab1(ByRef PageIn, ByVal bIsVisible)
  404.             
  405.         'If ( bIsVisible ) Then
  406.         %>
  407.  
  408.             <table width=518 valign=middle align=left border=0 cellspacing=0
  409.                    CELLPADDING=2 class="TasksBody">
  410.                    
  411.                        <TR>
  412.                     <TD colspan=6>
  413.                     <% CheckForSecureSite %>
  414.                     </TD>
  415.                 </TR>
  416.             
  417.                 <TR>
  418.                     <TD>
  419.                       
  420.                     </TD>
  421.                 </TR>
  422.                    
  423.                 <tr>
  424.                     <td width=25% nowrap>
  425.                         <%=L_USERNAME_TEXT %>
  426.                     </td>
  427.                     <td nowrap>
  428.                         <input TYPE="text" NAME="txtUserName"  SIZE="20" MAXLENGTH="20"  onfocus="this.select()" onkeyup="makeDisable(this)" onMouseOut="makeDisable(this)" value="<%=server.HTMLEncode(F_strUsername)%>">
  429.                     </td>
  430.                 </tr>
  431.                 <tr>
  432.                     <td width=25% nowrap>
  433.                         <%=L_FULLNAME_TEXT %>
  434.                     </td>
  435.                     <td nowrap>
  436.                         <input TYPE="text" NAME="txtFullName" SIZE="20" MAXLENGTH="25" onfocus="this.select()" value="<%=server.HTMLEncode(F_strFullname)%>">
  437.                     </td>
  438.                 </tr>
  439.                 <tr>
  440.                     <td width=25% nowrap>
  441.                     <%=L_DESCRIPTION_TEXT %>
  442.                     </td>
  443.                     <td>
  444.                         <input NAME="txtDescription" TYPE="text" SIZE="40" VALUE="<%=Server.HTMLEncode(F_strDescription)%>" maxlength=300>
  445.                     </td>
  446.                 </tr>
  447.                 <tr>
  448.                     <td width=25% nowrap>
  449.                         <% =L_PASSWORD_TEXT %>
  450.                     </td>
  451.                     <td nowrap>
  452.                         <input TYPE="password" NAME="pwdPassword" SIZE="20" MAXLENGTH="127" value="<%=server.HTMLEncode(F_strPassword)%>">
  453.                     </td>
  454.                 </tr>
  455.                 <tr>
  456.                     <td width=25% nowrap>
  457.                         <% =L_CONFIRMPASSWORD_TEXT %>
  458.                     </td>
  459.                     <td>
  460.                         <input TYPE="password" NAME="pwdConfirmPassword" SIZE="20" MAXLENGTH="127" value="<%=server.HTMLEncode(F_strConfirmpassword)%>">
  461.                     </td>
  462.                 </tr>
  463.                 <tr>
  464.                     <td width=25% nowrap>
  465.                         <% =L_HOMEDIRECTORY_TEXT %>
  466.                     </td>
  467.                     <td>
  468.                         <input TYPE="checkbox" value='1' <%=F_strHDIschecked%> class="FormCheckBox" NAME="chkHomePath" onclick="checkClick()">
  469.                         <% =L_HOMEPATH_TEXT %>
  470.                           
  471.                         <input TYPE="text" NAME="txtHomeDirectory" disabled SIZE="40" VALUE="<%=Server.HTMLEncode(F_strHomeDirectory)%>" maxlength=300>
  472.                         <input TYPE="hidden" NAME="hdnDefaultDir" VALUE="<%=Server.HTMLEncode(F_strDefaultHomeDir)%>" >
  473.                     </td>
  474.                 </tr>
  475.                 <tr>
  476.                     <td width=25% nowrap>
  477.                     </td>
  478.                     <td>
  479.                         <input TYPE="checkbox" value='1' <%=F_strIschecked%> class="FormCheckBox" NAME="chkUserDisabled">
  480.                         <%=L_USERDISABLED_TEXT    %>
  481.                     </td>
  482.                 </tr>
  483.  
  484.             </TABLE>
  485.         <%    
  486.          'End If
  487.         ServeTab1 = gc_ERR_SUCCESS
  488.     End Function
  489.  
  490.     '-------------------------------------------------------------------------
  491.     'Function:                ServeCommonJavaScript
  492.     'Description:            Serves in initialiging the values,setting the form
  493.     '                        data and validating the form values
  494.     'Input Variables:        None
  495.     'Output Variables:        None
  496.     'Returns:                None
  497.     'Global Variables:        L_PASSWORDNOTMATCH_ERRORMESSAGE
  498.     '-------------------------------------------------------------------------
  499.     Function ServeCommonJavaScript()
  500.     %>
  501.         <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  502.         </script>
  503.         <script language="JavaScript">
  504.         // Init Function
  505.         function Init()
  506.         {
  507.             if( document.frmTask.chkHomePath.checked == true )
  508.             {
  509.                 document.frmTask.txtHomeDirectory.style.backgroundColor = document.frmTask.style.backgroundColor;
  510.                 document.frmTask.txtHomeDirectory.disabled = false;
  511.                 document.frmTask.chkHomePath.value = "checked";
  512.                 document.frmTask.txtHomeDirectory.focus();
  513.                 document.frmTask.txtHomeDirectory.select();
  514.             }
  515.             else
  516.             {
  517.                 document.frmTask.txtUserName.focus();
  518.                 document.frmTask.txtUserName.select();
  519.                 document.frmTask.txtHomeDirectory.style.backgroundColor = 0xD3D3D3;
  520.                 document.frmTask.txtHomeDirectory.value = "";
  521.                 document.frmTask.txtHomeDirectory.disabled = true;
  522.                 document.frmTask.chkHomePath.value = "unchecked";
  523.             }
  524.  
  525.             // Set Cancel button status
  526.             EnableCancel();
  527.             // Set OK Button status
  528.             if ( document.frmTask.txtUserName )
  529.             {
  530.                 if ( document.frmTask.txtUserName.value.length < 1 )
  531.                     {
  532.                     DisableOK();
  533.                     }
  534.                 else
  535.                     {
  536.                     EnableOK();
  537.                     }
  538.             }        
  539.             
  540.             // for clearing error message when serverside error occurs
  541.             document.frmTask.onkeypress = ClearErr
  542.             return;
  543.         }
  544.  
  545.         // ValidatePage Function
  546.         // Returns: True if the page is OK, false if error(s) exist. 
  547.         function ValidatePage()
  548.         {
  549.             var objUsername=document.frmTask.txtUserName;
  550.             var strUsername=objUsername.value;
  551.  
  552.             //Blank Usename Validation
  553.             if (Trim(strUsername)=="")
  554.             {
  555.                 SA_DisplayErr("<%=Server.HTMLEncode(L_ENTERNAME_ERRORMESSAGE) %>");
  556.                 document.frmTask.onkeypress = ClearErr
  557.                 return false;
  558.             }
  559.  
  560.             //Password and comfirm password validation
  561.             if (document.frmTask.pwdPassword.value!=document.frmTask.pwdConfirmPassword.value)
  562.             {
  563.                 SA_DisplayErr("<%=Server.HTMLEncode(L_PASSWORDNOTMATCH_ERRORMESSAGE) %>");
  564.                 document.frmTask.onkeypress = ClearErr
  565.                 return false;
  566.              }
  567.  
  568.             // Checks For Invalid Key Entry
  569.             if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\\\\\]/",strUsername))
  570.             {
  571.                 SA_DisplayErr("<% =Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE) %>");
  572.                 document.frmTask.onkeypress = ClearErr
  573.                 return false;
  574.             }
  575.  
  576.             var bIsChecked = document.frmTask.chkHomePath.checked
  577.             if( bIsChecked == true )
  578.             {            
  579.                 var objHomeDirectory = document.frmTask.txtHomeDirectory;
  580.                 var strHomeDirectory = Trim(objHomeDirectory.value);
  581.                 var bStringValid = false;
  582.  
  583.                 if( strHomeDirectory == "" )
  584.                 {
  585.                     return true;
  586.                 }
  587.  
  588.                 
  589.                 do{
  590.                     
  591.                     if( !strHomeDirectory.match( /^[A-Za-z]:\\/ ) )
  592.                         break;
  593.                                                                
  594.                     if( strHomeDirectory.match( /\\{2,}/ ) )
  595.                         break;
  596.                         
  597.                     if( (strHomeDirectory.substr(2)).match( /[\/\*\?\|,;:"<>]/ ) )
  598.                         break;
  599.                         
  600.                     bStringValid = true;
  601.                                                            
  602.                 }while(false);
  603.                 
  604.                 if( !bStringValid )
  605.                 {                                   
  606.                     SA_DisplayErr("<%=Server.HTMLEncode(L_HOMEDIRECTORY_ERRORMESSAGE) %>");
  607.                     document.frmTask.onkeypress = ClearErr;
  608.                     return false;
  609.                 }
  610.             }
  611.             
  612.             return true;
  613.         }
  614.         
  615.         // function to make the Ok button disable
  616.         function makeDisable(objUsername)
  617.         {
  618.             var strUsername=objUsername.value;
  619.             if (Trim(strUsername)== "")
  620.                 DisableOK()
  621.             else
  622.                 EnableOK();
  623.         }
  624.         
  625.         function checkClick()
  626.         {
  627.             if( document.frmTask.chkHomePath.checked == true )
  628.             {
  629.                 document.frmTask.txtHomeDirectory.style.backgroundColor = document.frmTask.style.backgroundColor;
  630.                 document.frmTask.txtHomeDirectory.value = 
  631.                             document.frmTask.hdnDefaultDir.value + document.frmTask.txtUserName.value;
  632.                 document.frmTask.txtHomeDirectory.disabled = false;
  633.                 document.frmTask.chkHomePath.value = "checked";
  634.                 document.frmTask.txtHomeDirectory.focus();
  635.             }
  636.             else
  637.             {
  638.                 document.frmTask.txtHomeDirectory.style.backgroundColor = 0xD3D3D3;
  639.                 document.frmTask.txtHomeDirectory.value = "";
  640.                 document.frmTask.txtHomeDirectory.disabled = true;
  641.                 document.frmTask.chkHomePath.value = "unchecked";
  642.             }
  643.         }
  644.         
  645.         // SetData Function
  646.         function SetData()
  647.         {
  648.             //alert("SetData()");
  649.         }
  650.         </script>
  651.     <%
  652.     End Function
  653. %>
  654.